﻿using System;
using System.Web.Security;

namespace iss.sg4210.se18.team6s.Utilities
{
    public static class Common
    {
        private static Guid AnonymousUserId { get { return new Guid("0e6dd45d-5761-4c82-95b8-44f1c47e5307"); } }

        public static Guid GetLoggedInUserId()
        {
            MembershipUser user = Membership.GetUser(true);
            return user != null ? (Guid)user.ProviderUserKey : AnonymousUserId;
        }

        public static string GetLoggedInUserName()
        {
            MembershipUser user = Membership.GetUser(true);
            return user != null ? user.UserName : string.Empty;
        }

        public static bool IsLoggedInUserAdmin()
        {
            return Roles.IsUserInRole(GetLoggedInUserName(), ViewConstants.ROLE_ADMIN);
        }

        public static bool IsLoggedInUserAdvertiser()
        {
            return Roles.IsUserInRole(GetLoggedInUserName(), ViewConstants.ROLE_ADVERTISER);
        }
    }
}